package org.aplombh.java.leetcode.dailyTopic;

public class _1668最大重复子字符串数 {
    public static void main(String[] args) {
        System.out.println(new Solution1168_1().maxRepeating("ababac","aba"));
    }
}

// xxx
class Solution1168_1 {
    public int maxRepeating(String sequence, String word) {
        int count = 0;
        StringBuilder sb = new StringBuilder(word);
        while (sequence.contains(sb.toString())) {
            sb.append(word);
            count++;
        }
        return count;
    }
}

// xxx
class Solution1168_2 {
    public int maxRepeating(String sequence, String word) {
        int ret = 0;
        StringBuilder match = new StringBuilder(word);
        while (sequence.contains(match.toString())) {
            ret++;
            match.append(word);
        }
        return ret;
    }
}